<?php
//获取前端数据
$name=$_POST['name'];
$pwd=$_POST['pwd'];


//链接数据库  设置字符编码
$conn = mysqli_connect('localhost', 'root', 'root', '2008');
mysqli_query($conn, "set charset 'utf8'");
mysqli_query($conn, "set character set 'utf8'");

//SQL语句
$sql="insert into users (name,paw) values ('$name','$pwd')";

$res=mysqli_query($conn,$sql);


if ($res) {
    // 注册成功
    echo json_encode(array(
      "code" => 200,
      "body" => array(
        "msg" => "注册用户成功,是否跳转到登录页面？"
      )
    ));
  } else {
    echo json_encode(array(
      "code" => 201,
      "body" => array(
        "msg" => "用户注册失败,请重试"
      )
    ));
  }

?>